package com.bona.service.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.bona.dao.common.BaseDao;
import com.bona.dao.system.SysDataRuleDao;
import com.bona.model.system.SysDataRuleModel;
import com.bona.service.common.BaseService;
import com.bona.util.common.StringUtil;
import com.bona.util.common.UUIDGenerator;

@Service("dataRuleService")
@Transactional
public class SysDataRuleService extends BaseService {
	
	/**
	 * 添加数据规则
	 * @param model
	 */
	public void add(SysDataRuleModel model) {
		if (StringUtil.isEmpty(model.getId())) {	// 新增
			model.setId(UUIDGenerator.generate());
			dataRuleDao.add(model);
		} else {
			dataRuleDao.update(model);
		}
	}

	@Autowired
	private SysDataRuleDao dataRuleDao;
	
	@Override
	public BaseDao getDao() {
		return dataRuleDao;
	}

}
